﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Chowpoo.Sql;
using CourseSystem.Core.Entities;

namespace CourseSystem.Core.SqlServerDAL
{
    public class ExaminationDAL : CommonDal<ExaminationInfo>
    {
        public ExaminationDAL()
            : base(Settings.ConnectionName)
        {
        }

        public ExaminationDAL(string mConnectionStringName)
            : base(mConnectionStringName)
        {
        }


        public bool UpdateExaminationScore(int id)
        {
            using (var dc = DataContext<ExaminationInfo>.CreateContext(ConnectionStringName))
            {
                dc.Connection.Open();
                var cmd = new SqlCommand("UpdateExaminationScore") { CommandType = CommandType.StoredProcedure, Connection = (SqlConnection)dc.Connection };
                cmd.Parameters.AddWithValue("@Eid", id);
                using (var reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    try
                    {
                        dc.Translate(reader);
                        return true;
                    }
                    catch (Exception ex)
                    {
                        return false;
                    }
                }
            }


        }
    }
}
